#include "common.h"

int connect_host(char* ip, int port){
    int sock_fd;
    struct sockaddr_in seraddr;

    sock_fd = socket(AF_INET, SOCK_STREAM, 0);
    memset(&seraddr, 0, sizeof(seraddr));
    seraddr.sin_family = AF_INET;
    seraddr.sin_port = htons(port);
    if(inet_pton(AF_INET, ip, &seraddr.sin_addr) < 0){
        perror("inet_pton()");
    }

    connect(sock_fd, (struct sockaddr*)&seraddr, sizeof(seraddr));
    //printf("connect\n");

    return sock_fd;
}